#include "stdafx.h"

#include <QVariantMap>
#include "Item.h"

QVariantMap Item::toVariantMap() const
{
    return{
        { "keyword", this->keyword },
        { "title", this->title },
        { "id", this->id },
        { "price", this->price },
        { "shop", this->shop },
        { "link", this->link },
        { "imgsrc", this->imgsrc },
        { "location", this->location },
    };
}

Item Item::fromVariantMap(const QVariantMap &arg)
{
    Item item;

    item.keyword = arg.value("keyword").toString();
    item.title = arg.value("title").toString();
    item.id = arg.value("id").toULongLong();
    item.price = arg.value("price").toDouble();
    item.shop = arg.value("shop").toString();
    item.link = arg.value("link").toString();
    item.imgsrc = arg.value("imgsrc").toString();
    item.location = arg.value("location").toString();

    return item;
}
